<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	
	<xsl:include href="main.xsl"/>

	<!--
	page content
	-->
	<xsl:template name="content">
		<xsl:call-template name="formLayout">
			<xsl:with-param name="title" select="/root/gui/strings/categories"/>
			<xsl:with-param name="content">

				<form name="update" accept-charset="UTF-8" action="{/root/gui/locService}/metadata.category" method="post">
					<input name="id" type="hidden" value="{/root/response/id}"/>
					<xsl:variable name="lang" select="/root/gui/language"/>
					<table>
						<tr>
							<td>Categorias</td>
							<td>
							<select style="width:300px" class="content" name="id_category" id="id_category" onchange="updateCategoryList('id_group', 'groups_div', this.value );">
								<xsl:for-each select="/root/gui/categories/record">
									<option value="{id}">
										<xsl:if test="/root/request/id_category = id_category">
											<xsl:attribute name="selected"/>
										</xsl:if>
										<xsl:value-of select="label/child::*[name() = $lang]"/>
									</option>
								</xsl:for-each>
							</select>
							</td>						
						</tr>
						<tr>
							<td>Grupo</td>
							<td><div id="groups_div">No ha selecionado grupo</div></td>
						</tr>
						<tr>
							<td>Sub Grupo</td>
							<td><div id="sub_groups_div">No ha selecionado subgrupo</div></td>
						</tr>
						<tr height="10"><td colspan="2"></td></tr>
						<tr>
								<td>Categorias asignadas</td>
								<td style="padding-left:30px;">
									<table border="0" cellpadding="2" cellspacing="0" >
										<xsl:for-each select="/root/response/categories/category">
											<xsl:variable name="subGroupId" select="id"/>
											<xsl:variable name="groupId" select="groupId"/>
											<xsl:variable name="categoryId" select="categoryId"/>
											<xsl:if test="on">
												<tr>
													<td>[
														<xsl:for-each select="/root/gui/all_categories/record">
																<xsl:if test="$categoryId = id">
																	<xsl:value-of select="label/child::*[name() = $lang]"/>
																</xsl:if>
														</xsl:for-each>
														]
													</td>
													<td>[
														<xsl:for-each select="/root/gui/all_categories/record">
																<xsl:if test="$groupId = id">
																	<xsl:value-of select="label/child::*[name() = $lang]"/>
																</xsl:if>
														</xsl:for-each>
														]
													</td>
													<td><xsl:value-of select="label/child::*[name() = $lang]"/></td>
												</tr>
											</xsl:if>	
										</xsl:for-each>								
									</table>
								</td>
							</tr>
					</table>
				</form>
			</xsl:with-param>
			<xsl:with-param name="buttons">
                            <!--
				<button class="content" onclick="goBack()"><xsl:value-of select="/root/gui/strings/back"/></button>
                                -->
				&#160;
				<button class="content" onclick="goSubmit('update')"><xsl:value-of select="/root/gui/strings/submit"/></button>
			</xsl:with-param>
		</xsl:call-template>
	</xsl:template>
</xsl:stylesheet>
